<template>
  <div class="fixed" v-dialogDrag>
    <div class="content el-dialog"
         style="padding: 0">
      <div class="msgTop el-dialog__header">
        <span>播放录音</span>
        <i class="el-icon-close fr"
           style="cursor: pointer; line-height: 40px; font-size: 13px"
           @click="cancelTransfer"></i>
      </div>
      <div class="audioPops">
        <audio class="audiopopsPlay"
               :src="URLIP"
               controls="controls"
               ref="isAudioShow">
          Your browser does not support the audio element
        </audio>
      </div>
    </div>
  </div>
</template>

<script>
import { getVoiceInfo } from '@/api/workOrderController'
export default {
  props: ['voiceDataInfo'],
  data () {
    return {
      URLIP: '',
      ruleForm: {
      },
      rules: {
      },
      audioNone: true
    }
  },
  mounted () {
    //    this.getVoiceInfo(params)
  },
  methods: {
    getVoiceInfo (params) {
      let tenantId = sessionStorage.getItem('tenantId') || 'default'
      getVoiceInfo(params, this.$store.getters.userId, tenantId).then(res => {
        if (res.status === 200 && res.data.data.data && res.data.data.data.length !== 0) {
          // 如果有recordURL 优先使用 没有用recordURL2
          if (res.data.data.data[0].recordURL && res.data.data.data[0].recordURL !== '') {
            this.URLIP = result.data.data.data[0].recordURL
          } else if (res.data.data.data[0].recordURL2 && res.data.data.data[0].recordURL2 !== '') {
            this.URLIP = res.data.data.data[0].recordURL2
          } else {
            this.$message({
              type: "fail",
              message: "无语音数据!"
            });
            this.URLIP = ''
          }
        } else {
          this.$message({
            type: "fail",
            message: "无语音数据!"
          });
          this.URLIP = ''
        }
      })
    },
    cancelTransfer () {
      this.$refs['isAudioShow'].load()
      this.$emit('audioShow', false)
      this.audioNone = false
    }
  }
}
</script>

<style scoped>
.center {
  text-align: center;
  font-size: 16px;
}
.audioPops {
  height: 100px;
}
.audiopopsPlay {
  display: flex;
  margin: 50px auto;
}
.content {
  border-radius: 10px;
}
.msgTop {
  border-radius: 10px 10px 0px 0px;
}
.content {
    position: absolute;
    top: 40%;
    left: 25%;
    min-width:50%;
    transform: none;
    background: #ffffff;
    z-index: 999;
}
</style>
